
package com.dinzeer.slashblade_project_slr.client;


import com.dinzeer.slashblade_project_slr.regsiter.SLRItemRegsitry;
import mods.flammpfeil.slashblade.SlashBlade;
import mods.flammpfeil.slashblade.client.ClientHandler;
import mods.flammpfeil.slashblade.client.renderer.model.BladeModel;
import mods.flammpfeil.slashblade.item.ItemSlashBlade;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.world.item.Item;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ModelEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

@EventBusSubscriber(
        value = {Dist.CLIENT},
        bus = Bus.MOD
)
@OnlyIn(Dist.CLIENT)
public class ClientSetupHandler {
    @SubscribeEvent
    public static void setModelUser(FMLClientSetupEvent event) {
        SLRItemRegsitry.ITEMS.getEntries().forEach((blade) -> {
            if (blade.get() instanceof ItemSlashBlade) {
                ItemProperties.register((Item)blade.get(), SlashBlade.prefix("user"), (stack, level, entity, seed) -> {
                    BladeModel.user = entity;
                    return 0.0F;
                });
            }

        });
    }


    @SubscribeEvent
    public static void baked(ModelEvent.ModifyBakingResult event) {
        SLRItemRegsitry.ITEMS.getEntries().forEach((blade) -> {
            if (blade.get() instanceof ItemSlashBlade) {
                ClientHandler.bakeBlade((Item)blade.get(), event);
            }

        });
    }
}
